home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / PCBREG.SLT < prev    next >
Text File  |  1990-10-12  |  10KB  |  305 lines

  1. //-----------------------------------------------------------
  2. // PCBREG.SL? Automatic registration to a new MBBS.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs before you use it. Then recompile with CS PCBREG. 
  6. //-----------------------------------------------------------
  7.  
  8. str thisBBStype[]="PCB"      // Works only for PCBoard.
  9.    ,line   [80]              // Line for string storage.
  10.    ,help   [20]              // Line for string storage.
  11.                              // For the Global storage:
  12.    ,global   []="GLOBAL"     // Global script.
  13.    ,bbstype  []="BTYPE"      // BBS type.
  14.    ,hisprot  []="HPROT"      // BBS's protocol characters.
  15.    ,passw    []="PASSW"      // Current password.
  16.    ,addr     []="ADDR"       // Address
  17.    ,mail     []="MAIL"       // Mail address
  18.    ,state    []="STATE"      // Country
  19.    ,htel     []="HTEL"       // Home phone
  20.    ,wtel     []="WTEL"       // Work phone
  21.    ,cpu      []="CPU"        // Computer model
  22.    ;     
  23.  
  24. int tol = 300                            // No activity for ½ minute
  25.    ,stat, tmark                          // gives automatic exit.
  26.    ,i, norsk = 0
  27.    ;
  28.  
  29. //-----------------------------------------------------------
  30. // Script starts here.
  31. //-----------------------------------------------------------
  32.  
  33. main()
  34. {
  35. int error;
  36.  
  37.   entry();                               // Updates colors & status bar. 
  38.  
  39.   call (global,"R",bbstype,line);        // Get BBS type. Should be MBBS.
  40.  
  41.   if (line != thisBBStype)  
  42.   { wrongBBS();
  43.     return (-1);
  44.   }
  45.  
  46. // Only if online.
  47.  
  48.   if (!carrier())  
  49.   { alarm(1);
  50.     status_wind ("THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  51.     return (0);
  52.   }
  53.  
  54. // Start tracking incoming text. For ease of reading and programming,
  55. // and to improve the speed of the program on slow computers, this is
  56. // split into different sections.
  57. //-----------------------------------------------------------
  58.  
  59.   cputs ("C^M");                         // Continue registration.
  60.   if (waitfor ("register with us",10))
  61.     cputs ("Y^M");
  62.   else
  63.   { cputs ("n^M");
  64.     return (-1);
  65.   }
  66.   error = 0;
  67.   SECTION1();                            // These set error = -1
  68.                                          // by failure.
  69.   release();                             // Free timer and tracks.
  70.   if (error < 0) goto fail;
  71.  
  72.   SECTION2();
  73.   release();
  74.   if (!error)
  75.   { if (waitfor ("Command?",180))        // Command?
  76.     { cputs ("X^M");                     // Set Xpert mode.
  77.       waitfor ("Command?",10);           // Wait for next command.
  78.     }
  79.     goto done;                           // Return to caller.
  80.   }
  81. fail:
  82.    status_wind ("Registration failed!",20);
  83.    error = -1;            
  84.  
  85. done:
  86.    return (error);
  87. }
  88.  
  89. //-----------------------------------------------------------
  90. // Start registration.
  91. //-----------------------------------------------------------
  92.  
  93. SECTION1()
  94. {
  95. int c, error;
  96.                    // Variables ysed for text tracking:
  97. int pw             // Password
  98.    ,mo1, mo2       // More?
  99.    ,mo3, mo4       // (answer NO to these four prompts)
  100.    ,pro
  101.    ,ma             // Mail address
  102.    ,ci             // City calling from
  103.    ,cs             // City and state calling from
  104.    ;
  105.   error = -1;
  106.  
  107.   mo1= track ("(NS)non-stop?",0);        // More?
  108.   mo2= track ("(H)elp, More?",0);
  109.   mo3= track ("each message?",0);
  110.   mo4= track ("Message Base ",0);        // Scan message base?
  111.   pro= track ("Protocol Desi",0);        // Default protocol desired
  112.  
  113.   pw = track ("password",1);             // Password
  114.   ma = track ("dress?",0);               // Mail address
  115.   cs = track ("State calling",0);        // City and state calling from? 
  116.   ci = track ("City calling", 0);        // City calling from?
  117.   
  118.   tmark = timer_start (tol);             // wait up to 1 minute for 
  119.                                          // each response.
  120.   while ((stat=trig()) > 0)              // answer any questions.
  121.   { if (stat == pw)                      // Password
  122.       output (passw);
  123.    
  124.     else if (stat==mo1 || stat==mo2      // More?
  125.          ||  stat==mo3 || stat==mo4)
  126.       cputs ("n^M");                     // Not now please.
  127.  
  128.     else if (stat == pro)                // Default protocol
  129.       output (hisprot);
  130.  
  131.     else if (stat == ma)                 // Mail address
  132.       output (addr);
  133.  
  134.     if ((stat==ci) || (stat==cs))        // City (and state)?
  135.     { call (global,"R",mail,line);
  136.       for (i=0; i<strlen (line); ++i)
  137.       { c=subchr (line,i);               // Extract postnr. from string.
  138.         if (!isdigit(c) && c!=' ') break;
  139.       }
  140.       subchrs (line,i,20-i,help);
  141.       cputs (help);                      // give city.
  142.       if (stat == cs)
  143.       { cputs (" ");                     // Give country.
  144.         output (state);
  145.       }
  146.       else
  147.         cputs ("^M");                    // CR.
  148.       error = 0;
  149.       break;                             // This section done.         
  150.     }
  151.   }
  152.  
  153.   return (error);                        // Good or bad.
  154. }
  155.  
  156. //-----------------------------------------------------------
  157. // Section 2 of registration.
  158. //-----------------------------------------------------------
  159.  
  160. SECTION2()
  161. {
  162. int error;
  163.                    // Variables used for text tracking:
  164. int pw             // Please wait...
  165.    ,mo1, mo2       // More?
  166.    ,en             // Press (Enter) to continue: 
  167.    ,hp             // Home phone
  168.    ,wp             // Work phone
  169.    ,bc1, bc2       // Brand of CPU
  170.    ;
  171.   error = -1;                            // Start new trackings.
  172.  
  173.   wp = track ("data phone #",0);         // Business or data phone
  174.   hp = track ("oice phone #",0);         // Home or voice phone
  175.   en = track (" to continue",0);         // ENTER to continue.
  176.   pw = track ("Please Wait ",0);         // Please wait.
  177.   
  178.   mo1 = track ("(NS)non-stop?",0);       // More?
  179.   mo2 = track ("Message Base ",0);       // Scan message base?
  180.   bc1 = track ("CPU ",0);                // Brand of CPU in use.
  181.   bc2 = track ("Computer ",1);
  182.  
  183.   tmark = timer_start (tol);             // wait up to 1 minute for 
  184.                                          // each response.
  185.   while ((stat=trig()) > 0)              // answer any questions.
  186.   { if (stat==mo1 || stat==mo2)          // More?
  187.       cputs ("N^M");                     // Not now please.
  188.  
  189.     else if (stat == en)                   // ENTER to continue
  190.       cputs ("^M");
  191.  
  192.     else if (stat == hp)                   // Home phone number
  193.       output (htel);
  194.  
  195.     else if (stat == wp)                   // Work phone number
  196.       output (wtel);
  197.  
  198.     else if (stat==bc1 || stat==bc2)     // CPU type?
  199.       output (cpu);
  200.  
  201.     else if (stat == pw)                   // Please wait...
  202.     { error = 0;
  203.       break;
  204.     }
  205.   }
  206.   return (error);
  207. }
  208.  
  209. //-----------------------------------------------------------
  210. // Wrong BBS type.
  211. //-----------------------------------------------------------
  212.  
  213. wrongBBS()
  214. {
  215. str help[48];
  216.  
  217.     failtone();                          // Alarm.    
  218.     help = "This script is for ";        // Catenate strings.
  219.     strcat (help,thisBBStype);
  220.     strcat (help," only!");
  221.     status_wind (help,20);               // Display message for 2 sec.
  222. }
  223.  
  224. //-----------------------------------------------------------
  225. // Play fail tone.
  226. //-----------------------------------------------------------
  227.  
  228. failtone()
  229. {
  230.   int n;
  231.   for (n=140; n > 10; n = 100*n/120) 
  232.   { tone(n*10,12);                       // Fail tone!!
  233.     terminal();                          // Process text.
  234.   }
  235. }
  236.  
  237. //-----------------------------------------------------------
  238. // Routine to update colors and status bar.
  239. //-----------------------------------------------------------
  240.  
  241. entry ()
  242. {
  243.   _back_color = 1;
  244.   _fore_color = 14;
  245.   update_term();
  246. }
  247.  
  248. //-----------------------------------------------------------
  249. // Free timer and tracking functions.
  250. //-----------------------------------------------------------
  251.  
  252. release()
  253. {
  254.   timer_free (tmark);                    // fr